import logger from "../tools/logger";
import evn from "../config/evn";
const logo = `
              .oooooo.                                                              
             d'     \`b                                                              
oooo    ooo d' .d"bd  8  ooo. .oo.    .ooooo.  oooo    ooo          .ooooo.   .oooo.o 
 \`88b..8P'  8  8. 8  .d \`888P"Y88b  d88' \` 88b  \`88b..8P'          d88' \`88b d88(  "8 
   Y888'    Y.  YoP"b'   888   888  888ooo888    Y888'    8888888 888   888 \`"Y88b.  
 .o8"'88b    8.      .8  888   888  888    .o  .o8"'88b           888   888 o.  )88b 
o88'   888o   YooooooP  o888o o888o \`Y8bod8P' o88'   888o         \`Y8bod8P' 8""888P'

`;

export default () => {
    return new Promise((rej) => {
        const out = [
            "System loading com.Hacknet.Hacknet Lead to program",
            "Warning loading Error",
            "Detected x@nex-os.dll",
            "System loading  x@nex-os.dll Lead to program",
            "Mixin com.Hacknet.Hacknet",
            "target com.Hacknet.Main fix x@nex-os.dll",
            "target com.Hacknet.init fix x@nex-os.dll",
            "target com.Hacknet.Boot fix x@nex-os.dll",
            "target com.Hacknet.CPU.virtualization.counting.program fix x@nex-os.dll",
            "rooting via boot-uuid from /chosen: F567 0083- AC74-33D38361 -AC1977EE4AA2",
            "NTFS volume name BOOT. version 3.2. FIX in x@nex-os.dll",
            "Loaded os-config.sys : System Config Initialized",
            "Loaded bootcfg.dll : Boot Config Module Loaded",
            "Loaded netcfgx.dII : Network Config Module Loaded",
            "Load server.sys : UX Graphics Module Loaded",
            "UX Graphics Module Error",
            "AL lib: (EE) ALCmmdevPlayback_mixerProc: Failed to get padding: 0x88890004",
            "initialization ...",
            "Load terminal model ... ",
            "x@nex-os initialization process",
            logo,
            "Setting up environment variables...",
            `- Configuring system locale: ${evn().language}.UTF-8`,
            "- Setting system timezone: GMT+00:00",
            "Initializing device drivers...",
            "- Loading network driver... [OK]",
            "Running system diagnostics...",
            "- Checking disk health... [OK]",
            "- Checking memory integrity... [OK]",
            "- Checking network connectivity... [OK]",
            "- Checking peripheral devices... [OK]",
            "- Checking system security... [OK]",
            "Configuring network settings...",
            "- Obtaining IP address via DHCP... [OK]",
            "Starting system services...",
            "- Starting firewall service... [OK]",
            "Launching user interface...",
            "- Starting display manager... [Error]",
            "System boot completed successfully."
        ]
        const outConfig = {
            min: 0,
            max: out.length - 1,
            exported: 0,
            logger: false
        };
        const warning: number[] = [
            1, 3, 4, 5, 6, 7, 8, 9
        ]
        const debug: number[] = [11]
        const error: number[] = [16]

        const timer = setInterval(() => {
            if (outConfig.exported === outConfig.max) {
                clearInterval(timer);
                rej(true)
            }
            for (let x of warning) {
                if (x == outConfig.exported) {
                    logger.warn(out[outConfig.exported]);
                    outConfig.logger = true
                }
            }
            for (let x of error) {
                if (x == outConfig.exported) {
                    logger.error(out[outConfig.exported]);
                    outConfig.logger = true
                }
            }
            for (let x of debug) {
                if (x == outConfig.exported) {
                    logger.debug(out[outConfig.exported]);
                    outConfig.logger = true
                }
            }
            if (!outConfig.logger) {
                logger.info(out[outConfig.exported])
            }
            outConfig.exported = outConfig.exported + 1;
            outConfig.logger = false
        }, 100);
    })
}

export {logo}